/*
 * @Autor: taobo
 * @Date: 2020-06-08 18:30:16
 * @LastEditTime: 2020-06-10 11:10:29
 */ 
#include <bits/stdc++.h>
using namespace std;
//暴力法解字符串转整型函数stoi
class stoi_1 {
public:
    int strToInt(string str) {
        int flag = 1;
        bool start = false;
        int ans = 0;
        for(char& c:str){
            if(c=='-' && !start){
                flag = -1;
                start = true;
            }else if(c=='+' && !start){
                start = true;
            }else if(c==' ' && !start){
                continue;
            }else if(isdigit(c)){
                start = true;
                int total = ans*flag;
                if(total>INT_MAX/10 || (total==INT_MAX/10 && (c-'0')>=INT_MAX%10))
                    return INT_MAX;
                if(total<INT_MIN/10 || (total==INT_MIN/10 && (c-'0')>=0-(INT_MIN%10)))
                    return INT_MIN;
                ans = ans*10 + (c-'0');
            }else{
                break;
            }
        }
        return ans*flag;
    }
};



int main ()
{
  stoi_1 obj1;
  int ans1 = obj1.strToInt("-1233334tyeesdd\n");
  cout <<"violence: "<<ans1<<'\n';
  return 0;
}